<template>
  <div class="repayment">

<div>  
<el-form :model="ruleForm" status-icon :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">

 
  <el-form-item label="催收方式" prop="manner">
    <el-input type="textarea" v-model="ruleForm.manner"></el-input>
  </el-form-item>
<el-form-item label="催收内容" prop="content">
    <el-input type="textarea" v-model="ruleForm.content"></el-input>
  </el-form-item>

  <el-form-item>
    <el-button type="primary" @click="submitForm('ruleForm')">提交</el-button>
    <el-button @click="resetForm('ruleForm')">重置</el-button>
  </el-form-item>
</el-form>
</div>
  </div>
</template>

<script>
export default {
  data () {
   var checkAge = (rule, value, callback) => {
        if (!value) {
          return callback(new Error('催收方式不能为空'));
        }
        setTimeout(() => {
          if (Number.isInteger(value)) {
            callback(new Error('请输入数字值'));
          } else {
            if (value < 18) {
              callback(new Error('必须年满18岁'));
            } else {
              callback();
            }
          }
        }, 1000);
      };
      var validatePass = (rule, value, callback) => {
        if (value === '') {
          callback(new Error('请输入密码'));
        } else {
          if (this.ruleForm.checkPass !== '') {
            this.$refs.ruleForm.validateField('checkPass');
          }
          callback();
        }
      };
      var validatePass2 = (rule, value, callback) => {
        if (value === '') {
          callback(new Error('请再次输入密码'));
        } else if (value !== this.ruleForm.pass) {
          callback(new Error('两次输入密码不一致!'));
        } else {
          callback();
        }
      };
    return {
      
       ruleForm: {
          pass: '',
          time: '',
          manner: '',
           content: ''
        },
        rules: {
         pass: [
            { validator: validatePass, trigger: 'blur' }
          ],
          time: [
            { type: 'date', required: true, message: '请选择日期', trigger: 'change' }
          ],
          manner: [
            { validator: checkAge, trigger: 'blur' }
          ],
          content: [
            { required: true, message: '请填写催收内容', trigger: 'blur' }
          ]
        },
      
      pageSize:7,
     
      totalRecord:this.totalRecord,
       currentPage4: 1,
     tableData: [],
      formInline: {
          user: '',
          region: ''
        }
    }
  },
  created(){
      this.init()
      
      var oid=this.$route.query.oid
      console.log("oid是"+oid)
  },

  methods:{
     onSubmit() {
        console.log('submit!');
        this.$axios.get("http://localhost:8082/loanmanage/selcetByname", 
        {params: {
            enterprisename:this.formInline.enterprisename,
            code:this.formInline.code
        }}).then(resp=>{
    
          console.log(resp)
        })
      },
     handleSizeChange(val) {
       this.pageSize=val
        console.log(`每页 ${val} 条`);
         this.init();
      },
      handleCurrentChange(val) {
          this.currentPage4=val
        console.log(`当前页: ${val}`);
        this.init();
      },
    handleClick(row) {
        console.log(row);
      },
    init(){
     
       console.log("row");
      //   // var reid=this.$route.query.reid
      // this.$axios
      //   .get("http://localhost:8082/RepaymentRegistered/RepaymentReid", {
      //     params: {
            
      //       reid:reid
      //     }
      //   })
      //   .then(resp => {
      //    this.ruleForm=resp.data
      //    console.log(resp);
      //   });
    },
    submitForm(formName) {
      
        this.$refs[formName].validate((valid) => {
          if (valid) {
            alert('submit!');
 var oid=this.$route.query.oid
//   console.log("formName------"+this.ruleForm.repaymentdate)

console.log("formName------"+this.ruleForm.manner)

          this.$axios
        .get("http://localhost:8082/CollectionRecords/CollectionRecordsIntert", {
          params: {
            time:this.ruleForm.time,
            manner:this.ruleForm.manner,
            content:this.ruleForm.content,
       
           oid:oid,
        
          }
        })
        .then(resp => {
        
        });

 this.$router.push("/repayment");





          } else {
            console.log('error submit!!');
            return false;
          }
        });
      },
      resetForm(formName) {
        this.$refs[formName].resetFields();
      }
    
  }
}
</script>

<style >
.block{
 position: relative;
 left: 350px;
 top: 200px;


}


</style>